﻿#ifndef OSGI_PREDEFINED_H__
#define OSGI_PREDEFINED_H__

#define OSGI_NAMESPACE                  MicroKernelRuntime
#define OSGI_NAMESPACE_BEGIN            namespace OSGI_NAMESPACE {
#define OSGI_NAMESPACE_END              }
#define MicroKernel_Namespace           MicroKernelRuntime
#define Begin_MicroKernel_Namespace(s)  namespace s {
#define End_MicroKernel_Namespace()     }

#define LEVEL_EXCHANGE_HIGH             1
#define LEVEL_EXCHANGE_GENERAL          2
#define LEVEL_EXCHANGE_LOW              3

//接口返回值
#define SUCCESS                         0
#define USUAL_ERROR                     -1
#define UNRESOLVED_ERROR                -2

#define APIENTRY
#define HMODULE                         void*
#define BOOL                            int
#define TRUE                            1
#define FALSE                           0

#define BUNDLE_PATH                     "BundlePath"
#define APP_PATH                        "AppPath"
#define OSGI_DO_STRINGIZE(X)            #X
#define OSGI_STRINGIZE(X)               OSGI_DO_STRINGIZE(X)

#define OSGI_INTERFACE                  struct
#define OSGI_BUNDLE_ACTIVATOR_SYMBOL    K5_Bundle_Activator
#define OSGI_BUNDLE_ACTIVATOR_STRING    OSGI_STRINGIZE(OSGI_BUNDLE_ACTIVATOR_SYMBOL)

#define OSGI_BUNDLE_ACTIVATOR() \
    extern "C" OSGI_EXPORT_SYMBOL OSGI_NAMESPACE::IBundleActivator * OSGI_API OSGI_BUNDLE_ACTIVATOR_SYMBOL()


#ifdef _WINDOWS
//for windows
#define OSGI_API  __cdecl

#define OSGI_EXPORT_SYMBOL __declspec(dllexport)
#define OSGI_IMPORT_SYMBOL __declspec(dllimport)
#define OSGI_EXPORT
#ifdef OSGI_EXPORT
#define OSGI_SYMBOL OSGI_EXPORT_SYMBOL
#else
#define OSGI_SYMBOL OSGI_IMPORT_SYMBOL
#endif
#define MKRAPI  __cdecl
#ifndef MTK_DLL_IMPORT
#define MTK_DLL_API __declspec(dllexport)
#else
#define MTK_DLL_API __declspec(dllimport)
#endif
#else
//for linux
#include <dlfcn.h>

#define LPCTSTR                         const char*
#define FARPROC                         void*
#define LPVOID                          void*

#ifndef DWORD
#define DWORD                           unsigned long
#endif

#define MKRAPI                          __attribute__((__cdecl__))
#define OSGI_API                        __attribute__((__cdecl__))
#define OSGI_EXPORT_SYMBOL              __attribute__((visibility("default")))
#define MTK_DLL_API                     __attribute__((visibility("default")))
#endif

OSGI_NAMESPACE_BEGIN

OSGI_INTERFACE IManifest;
OSGI_INTERFACE ISystemInitializer;
OSGI_INTERFACE IEvent;
OSGI_INTERFACE IService;
OSGI_INTERFACE IServiceEvent;
OSGI_INTERFACE IServiceEventListener;
OSGI_INTERFACE IServiceManager;
OSGI_INTERFACE IAllocator;
OSGI_INTERFACE IBundle;
OSGI_INTERFACE IBundleContext;
OSGI_INTERFACE IBundleEvent;
OSGI_INTERFACE IBundleEventListener;
OSGI_INTERFACE ISystemEvent;
OSGI_INTERFACE IDictionary;
OSGI_INTERFACE IUiWidgetCmdEnumer;
OSGI_INTERFACE IUiWidgetCmdNotify;
OSGI_INTERFACE IUIWidget;
OSGI_INTERFACE IHttpRequest;
OSGI_INTERFACE IHttpService;
OSGI_INTERFACE IMemBufReader;
OSGI_INTERFACE IMsgBroker;
OSGI_INTERFACE IMonitorFactory;
OSGI_INTERFACE IDBSERVICE;


typedef void* (OSGI_API *K5_Bundle_Activator_func)(void);

OSGI_NAMESPACE_END



#endif // OSGI_PREDEFINED_H__
